package com.linsir.lin.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.IService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.linsir.lin.mapper.MemberOrganMapper;
import com.linsir.lin.pojo.MemberOrgan;
import com.linsir.lin.service.MemberOrganService;
import org.springframework.stereotype.Service;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ：linsir
 * @date ：Created in 2021/7/9 11:28
 * @description：接口实现
 * @modified By：
 * @version: 1.0.0
 */
@Service
public class MemberOrganServiceImpl extends ServiceImpl<MemberOrganMapper,MemberOrgan> implements IService<MemberOrgan>, MemberOrganService {
    @Override
    public List<Integer> getMIdsByOId(Integer oranId) {
        QueryWrapper<MemberOrgan> queryWrapper = new QueryWrapper<MemberOrgan>().eq("oran_id",oranId);
        List<Integer> mIds= new ArrayList<Integer>();
        list(queryWrapper).forEach(m-> mIds.add(m.getMeberId()));
        return mIds;
    }

    @Override
    public List<Integer> getOIdsByMId(Integer memberId) {
        QueryWrapper<MemberOrgan> queryWrapper = new QueryWrapper<MemberOrgan>().eq("member_id",memberId);
        List<Integer> oIds= new ArrayList<Integer>();
        List<MemberOrgan> memberOrgans = list(queryWrapper);
        memberOrgans.forEach(m-> oIds.add(m.getOranId()));
        return oIds;
    }
}
